With the 'update' attribute you can set a script file that is called every few ticks. You can use world and origin for your script.
update="loader.loadScript('xyz.script');";